package cn.richx.pushmessage.domain;

import cn.richx.pushmessage.message.PushItem;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A PushMessage.
 */
@Entity
@Table(name = "pushmessage")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class PushMessage implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "push_id")
    private Long pushId;

    @Column(name = "channels")
    private String channels;

    @Column(name = "create_time")
    private String createTime;

    @Column(name = "device_type")
    private String deviceType;

    @Column(name = "operationapply_id")
    private String operationapplyId;

    @Column(name = "oaapply_id")
    private String oaapplyId;

    @Column(name = "operation_result")
    private String operationResult;

    @Column(name = "push_content")
    private String pushContent;

    @Column(name = "push_content_type")
    private Integer pushContentType;

    @Column(name = "push_data")
    private String pushData;

    @Column(name = "push_group_id")
    private String pushGroupId;

    @Column(name = "push_group_name")
    private String pushGroupName;

    @Column(name = "push_image")
    private String pushImage;

    @Column(name = "push_owner_id")
    private String pushOwnerID;

    @Column(name = "push_sender")
    private String pushSender;

    @Column(name = "push_sender_id")
    private String pushSenderId;

    @Column(name = "push_sender_voip_account")
    private String pushSenderVoipAccount;

    @Column(name = "push_type")
    private Integer pushType;

    @Column(name = "push_url")
    private String pushUrl;

    @Column(name = "receiver_id")
    private String receiverId;

    @Column(name = "sound")
    private String sound;

    @Column(name = "status")
    private Integer status;

    @Column(name = "title")
    private String title;

    @Column(name = "school_id")
    private String schoolId;

    @Column(name = "alert")
    private String alert;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove

    public Long getPushId() {
        return pushId;
    }

    public PushMessage pushId(Long pushId) {
        this.pushId = pushId;
        return this;
    }

    public void setPushId(Long pushId) {
        this.pushId = pushId;
    }

    public String getChannels() {
        return channels;
    }

    public PushMessage channels(String channels) {
        this.channels = channels;
        return this;
    }

    public void setChannels(String channels) {
        this.channels = channels;
    }

    public String getCreateTime() {
        return createTime;
    }

    public PushMessage createTime(String createTime) {
        this.createTime = createTime;
        return this;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public PushMessage deviceType(String deviceType) {
        this.deviceType = deviceType;
        return this;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public String getOperationapplyId() {
        return operationapplyId;
    }

    public PushMessage operationapplyId(String operationapplyId) {
        this.operationapplyId = operationapplyId;
        return this;
    }

    public void setOperationapplyId(String operationapplyId) {
        this.operationapplyId = operationapplyId;
    }

    public String getOaapplyId() {
        return oaapplyId;
    }

    public PushMessage oaapplyId(String oaapplyId) {
        this.oaapplyId = oaapplyId;
        return this;
    }

    public void setOaapplyId(String oaapplyId) {
        this.oaapplyId = oaapplyId;
    }

    public String getOperationResult() {
        return operationResult;
    }

    public PushMessage operationResult(String operationResult) {
        this.operationResult = operationResult;
        return this;
    }

    public void setOperationResult(String operationResult) {
        this.operationResult = operationResult;
    }

    public String getPushContent() {
        return pushContent;
    }

    public PushMessage pushContent(String pushContent) {
        this.pushContent = pushContent;
        return this;
    }

    public void setPushContent(String pushContent) {
        this.pushContent = pushContent;
    }

    public Integer getPushContentType() {
        return pushContentType;
    }

    public PushMessage pushContentType(Integer pushContentType) {
        this.pushContentType = pushContentType;
        return this;
    }

    public void setPushContentType(Integer pushContentType) {
        this.pushContentType = pushContentType;
    }

    public String getPushData() {
        return pushData;
    }

    public PushMessage pushData(String pushData) {
        this.pushData = pushData;
        return this;
    }

    public void setPushData(String pushData) {
        this.pushData = pushData;
    }

    public String getPushGroupId() {
        return pushGroupId;
    }

    public PushMessage pushGroupId(String pushGroupId) {
        this.pushGroupId = pushGroupId;
        return this;
    }

    public void setPushGroupId(String pushGroupId) {
        this.pushGroupId = pushGroupId;
    }

    public String getPushGroupName() {
        return pushGroupName;
    }

    public PushMessage pushGroupName(String pushGroupName) {
        this.pushGroupName = pushGroupName;
        return this;
    }

    public void setPushGroupName(String pushGroupName) {
        this.pushGroupName = pushGroupName;
    }

    public String getPushImage() {
        return pushImage;
    }

    public PushMessage pushImage(String pushImage) {
        this.pushImage = pushImage;
        return this;
    }

    public void setPushImage(String pushImage) {
        this.pushImage = pushImage;
    }

    public String getPushOwnerID() {
        return pushOwnerID;
    }

    public PushMessage pushOwnerID(String pushOwnerID) {
        this.pushOwnerID = pushOwnerID;
        return this;
    }

    public void setPushOwnerID(String pushOwnerID) {
        this.pushOwnerID = pushOwnerID;
    }

    public String getPushSender() {
        return pushSender;
    }

    public PushMessage pushSender(String pushSender) {
        this.pushSender = pushSender;
        return this;
    }

    public void setPushSender(String pushSender) {
        this.pushSender = pushSender;
    }

    public String getPushSenderId() {
        return pushSenderId;
    }

    public PushMessage pushSenderId(String pushSenderId) {
        this.pushSenderId = pushSenderId;
        return this;
    }

    public void setPushSenderId(String pushSenderId) {
        this.pushSenderId = pushSenderId;
    }

    public String getPushSenderVoipAccount() {
        return pushSenderVoipAccount;
    }

    public PushMessage pushSenderVoipAccount(String pushSenderVoipAccount) {
        this.pushSenderVoipAccount = pushSenderVoipAccount;
        return this;
    }

    public void setPushSenderVoipAccount(String pushSenderVoipAccount) {
        this.pushSenderVoipAccount = pushSenderVoipAccount;
    }

    public Integer getPushType() {
        return pushType;
    }

    public PushMessage pushType(Integer pushType) {
        this.pushType = pushType;
        return this;
    }

    public void setPushType(Integer pushType) {
        this.pushType = pushType;
    }

    public String getPushUrl() {
        return pushUrl;
    }

    public PushMessage pushUrl(String pushUrl) {
        this.pushUrl = pushUrl;
        return this;
    }

    public void setPushUrl(String pushUrl) {
        this.pushUrl = pushUrl;
    }

    public String getReceiverId() {
        return receiverId;
    }

    public PushMessage receiverId(String receiverId) {
        this.receiverId = receiverId;
        return this;
    }

    public void setReceiverId(String receiverId) {
        this.receiverId = receiverId;
    }

    public String getSound() {
        return sound;
    }

    public PushMessage sound(String sound) {
        this.sound = sound;
        return this;
    }

    public void setSound(String sound) {
        this.sound = sound;
    }

    public Integer getStatus() {
        return status;
    }

    public PushMessage status(Integer status) {
        this.status = status;
        return this;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getTitle() {
        return title;
    }

    public PushMessage title(String title) {
        this.title = title;
        return this;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSchoolId() {
        return schoolId;
    }

    public PushMessage schoolId(String schoolId) {
        this.schoolId = schoolId;
        return this;
    }

    public void setSchoolId(String schoolId) {
        this.schoolId = schoolId;
    }

    public String getAlert() {
        return alert;
    }

    public PushMessage alert(String alert) {
        this.alert = alert;
        return this;
    }

    public void setAlert(String alert) {
        this.alert = alert;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove


    public PushMessage() {}

    public PushMessage(PushItem pushItem) {
        this.pushType = pushItem.getPushType();
        this.pushContentType = pushItem.getPushContentType();
        this.pushContent = pushItem.getPushContent();
        this.pushImage = pushItem.getPushImage();
        this.pushSenderId = String.valueOf(pushItem.getPushSenderId());
        this.pushSender = pushItem.getPushSender();
        this.pushSenderVoipAccount = pushItem.getPushSenderVoipAccount();
        this.pushGroupId = String.valueOf(pushItem.getPushGroupId());
        this.pushGroupName = pushItem.getPushGroupName();
        this.pushUrl = pushItem.getPushUrl();
        this.createTime = System.currentTimeMillis() + "";
        this.operationapplyId = String.valueOf(pushItem.getOperationapplyId());
        this.oaapplyId = pushItem.getOAApplyId();
        this.title = pushItem.getTitle();
        this.channels = pushItem.getChannels();
        this.deviceType = pushItem.getDeviceType();
        this.receiverId = String.valueOf(pushItem.getReceiverId());
        this.pushOwnerID = pushItem.getPushOwnerID() + "";
        this.operationResult = String.valueOf(pushItem.getOperationResult());
        this.pushData = pushItem.getPushData();
        if (pushItem.getAps() != null) {
            if (pushItem.getAps().get("alert") != null) {
                this.alert = (String) pushItem.getAps().get("alert");
            }
            if (pushItem.getAps().get("sound") != null) {
                this.sound = (String) pushItem.getAps().get("sound");
            }
        }
        this.schoolId = pushItem.getSchoolId();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PushMessage pushMessage = (PushMessage) o;
        if (pushMessage.getPushId() == null || getPushId() == null) {
            return false;
        }
        return Objects.equals(getPushId(), pushMessage.getPushId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getPushId());
    }

    @Override
    public String toString() {
        return "PushMessage{" +
            ", pushId=" + getPushId() +
            ", channels='" + getChannels() + "'" +
            ", createTime='" + getCreateTime() + "'" +
            ", deviceType='" + getDeviceType() + "'" +
            ", operationapplyId='" + getOperationapplyId() + "'" +
            ", oaapplyId='" + getOaapplyId() + "'" +
            ", operationResult='" + getOperationResult() + "'" +
            ", pushContent='" + getPushContent() + "'" +
            ", pushContentType=" + getPushContentType() +
            ", pushData='" + getPushData() + "'" +
            ", pushGroupId='" + getPushGroupId() + "'" +
            ", pushGroupName='" + getPushGroupName() + "'" +
            ", pushImage='" + getPushImage() + "'" +
            ", pushOwnerID='" + getPushOwnerID() + "'" +
            ", pushSender='" + getPushSender() + "'" +
            ", pushSenderId='" + getPushSenderId() + "'" +
            ", pushSenderVoipAccount='" + getPushSenderVoipAccount() + "'" +
            ", pushType=" + getPushType() +
            ", pushUrl='" + getPushUrl() + "'" +
            ", receiverId='" + getReceiverId() + "'" +
            ", sound='" + getSound() + "'" +
            ", status=" + getStatus() +
            ", title='" + getTitle() + "'" +
            ", schoolId='" + getSchoolId() + "'" +
            ", alert='" + getAlert() + "'" +
            "}";
    }
}
